import { rqtGetCheckCodeImg } from '@/services/common'
import { createImgObj } from '@/utils/public/file'

export default {
  data() {
    return {
      codeCheckImg: undefined,
      codeUuidKey: undefined,
      isCodeLoading: false
    }
  },
  methods: {
    onFreshCodeClick() {
      this.handleCodeImg()
    },
    handleCodeImg() {
      this.isCodeLoading = true
      rqtGetCheckCodeImg()
        .then(res => {
          this.codeCheckImg = createImgObj(res)
          this.codeUuidKey = res.headers.uuid_key
          this.isCodeLoading = false
        })
        .catch(() => {
          this.isCodeLoading = false
        })
    }
  }
}
